~ chicken-core (master) /manual/Module (chicken repl)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken repl)
5
6This module provides procedures you can use to create your own
7Read-Eval-Print Loop (REPL).
8
9=== repl
10
11<procedure>(repl [EVALUATOR])</procedure>
12
13Start a new read-eval-print loop. Sets the {{reset-handler}} so that
14any invocation of {{reset}} restarts the read-eval-print loop. Also
15changes the current exception-handler to display a message, write
16any arguments to the value of {{(current-error-port)}} and reset.
17
18If {{EVALUATOR}} is given, it should be a procedure of one argument that
19is used in place of {{eval}} to evaluate each entered expression.
20
21You can use {{quit}} to terminate the current read-eval-print loop.
22Encountering end-of-file also terminates the current REPL.
23
24
25=== repl-prompt
26
27<parameter>(repl-prompt)</parameter>
28
29A procedure that should evaluate to a string that will be printed before
30reading interactive input from the user in a read-eval-print loop.
31Defaults to {{(lambda () "#;N> ")}}.
32
33
34=== quit
35
36<procedure>(quit [RESULT])</procedure>
37
38In the interpreter {{quit}} exits the currently active read-eval-print
39loop. In compiled code, it is equivalent to calling {{exit}}. See
40also the {{repl}} procedure.
41
42
43=== reset
44
45<procedure>(reset)</procedure>
46
47Reset program (Invokes {{reset-handler}}).
48
49
50=== reset-handler
51
52<parameter>(reset-handler)</parameter>
53
54A procedure of zero arguments that is called via {{reset}}. The
55default behavior in compiled code is to invoke the value of
56{{(exit-handler)}}. The default behavior in the interpreter is to
57abort the current computation and to restart the read-eval-print loop.
58
59---
60Previous: [[Module (chicken read-syntax)]]
61
62Next: [[Module (chicken sort)]]